#
#   __init__.py.py
#   DrAnn
#
#   Created by luoxh on 2019-07-15-10:49.
#   Copyright © 2019 luoxh. All rights reserved.
#
from datetime import datetime

from mongoengine import (DateTimeField, Document, )


class BaseDocument(Document):
    creation_date = DateTimeField()
    modified_date = DateTimeField(default=datetime.now)

    meta = {'allow_inheritance': True, 'abstract': True, }

    def clean(self):
        if not self.creation_date: self.creation_date = datetime.now()
        self.modified_date = datetime.now()
